import request from '@/utils/request'
/**
 * 获取订单列表
 * @param page      当前第几页
 * @param pageSize  每页多少条
 * @param status    订单状态    1待取件2已取件3派件成功
 * @param express_id 快递站点的ID
 * @param pay_status 订单的支付状态     1待支付2支付成功3支付失败4退款5申请退款
 * @param name 用户名字
 * @param mobile 用户电话
 * @param dormitory_id 楼栋ID
 * @returns 
 */
export function apiGetOrderList(param) {
    let startTime = '',
        endTime = '';
    if (param.time) {
        startTime = param.time[0];
        endTime = param.time[1];
    }
    return request({
        url: '/take-user/send',
        method: 'GET',
        params: {
            page: param.page,
            pageSize: param.pageSize,
            status: param.status,
            express_id: param.express_id,
            pay_status: param.pay_status,
            name: param.name,
            mobile: param.mobile,
            dormitory_id: param.dormitory_id,
            startTime,
            endTime

        }
    })
}

/**
 * 
 * @param  id  订单ID
 * @param status 订单状态    1待取件   2已取件  3已完成
 * @returns 
 */
export function apiSetOrderStatus(param) {
    return request.post(`/take-user/edit-status?id=${param.id}`, {
        status: param.status
    })
}


/**
 * 
 * @param  id  订单ID
 * @param refund_amount 金额
 * @returns 
 */
export function apiSetRefund(param) {
    return request({
        method: 'post',
        url: '/order/refund',
        data: {
            id: param.id,
            refund_amount: param.refund_amount
        }
    })
}